package cn.ren.cloud.controller;

import cn.ren.cloud.result.JsonResult;
import cn.ren.cloud.service.ITokenService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 23508
 */
@RestController
@RequestMapping("/token")
public class TokenController {

    private final ITokenService tokenService;

    public TokenController(ITokenService tokenService) {
        this.tokenService = tokenService;
    }

    /**
     * 通过ID获取token
     *
     * @param courseId 课程ID
     * @return Token码
     */
    @RequestMapping(value = "/createToken/{courseId}", method = RequestMethod.GET)
    public JsonResult createToken(@PathVariable("courseId") Long courseId) {
        return JsonResult.success(tokenService.getCreateToken(courseId));
    }
}
